package hdp.test;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.apache.commons.dbutils.handlers.MapListHandler;

import com.google.gson.Gson;
import com.sun.org.apache.bcel.internal.generic.NEW;

import dao.ActivityDao;
import dao.FoodDao;
import dao.impl.ActivityImpl;
import dao.impl.BaseDao;
import dao.impl.FoodDaoImpl;

public class indextest {
	static FoodDao fdao = new FoodDaoImpl();
	static ActivityDao adao = new ActivityImpl();

	public static void main(String[] args) throws Exception {
		fdao.selectAddressDInterestF("1_2_1");
//		fdao.selectAddressDInterestF2("1_2_1");
//		fdao.selectAddressDInterestF3("1_2_1");
//		fdao.selectAddressDInterestF4("1_2_1");
//		fdao.selectAddressDInterestF5("1_2_1");
//		fdao.selectAddressDInterestF6("1_2_1");

//		fdao.selectAddressWInterestF1("1_2_1");
//		fdao.selectAddressWInterestF2(null);
//		fdao.selectAddressWInterestF2("1_2_1");
//		fdao.selectAddressWInterestF3("1_2_1");
//		fdao.selectAddressWInterestF4("1_2_1");
//		fdao.selectAddressWInterestF5("1_2_1");
//		fdao.selectAddressWInterestF6("1_2_1");
//		
//		fdao.selectAddressZInterestF1("1_2_1");
//		fdao.selectAddressZInterestF2("1_2_1");
//		fdao.selectAddressZInterestF3("1_2_1");
//		fdao.selectAddressZInterestF4("1_2_1");
//		fdao.selectAddressZInterestF5("1_2_1");
//		fdao.selectAddressZInterestF6("1_2_1");
//		
//		fdao.selectAddressXInterestF1("1_2_1");
//		fdao.selectAddressXInterestF2("1_2_1");
//		fdao.selectAddressXInterestF3("1_2_1");
//		fdao.selectAddressXInterestF4("1_2_1");
//		fdao.selectAddressXInterestF5("1_2_1");
//		fdao.selectAddressXInterestF6("1_2_1");
//		
//		fdao.selectAddressYInterestF1("1_2_1");
//		fdao.selectAddressYInterestF2("1_2_1");
//		fdao.selectAddressYInterestF3("1_2_1");
//		fdao.selectAddressYInterestF4("1_2_1");
//		fdao.selectAddressYInterestF5("1_2_1");
//		fdao.selectAddressYInterestF6("1_2_1");

//		String foodaddress="0_0_0";
//		Integer foodtime1=5;
//		Integer foodtime2=11;
//		String sql="SELECT a.*,p.c FROM (SELECT * FROM food WHERE NOW()<foodtime \r\n" + 
//				"AND foodaddress=? AND hour(foodtime) between  ? and ?) a,photo p \r\n" + 
//				"WHERE a.foodid=p.suozaiid AND p.phototype=1 AND p.zhufu=1 ORDER BY a.interest DESC LIMIT 5";
//		List<Map<String, Object>> queryList=BaseDao.query.query(sql, new MapListHandler(),foodaddress,foodtime1,foodtime2);
//		
//		System.out.println(new Gson().toJson(queryList));

//		String sql="select * from photo";
		String sql = "SELECT p.*,u.*,a.* FROM (SELECT foodid,hosterid,foodtitle,foodprice,foodjoinernum,foodtime,foodaddress,foodintroduction,interest \r\n"
				+ "FROM food WHERE NOW()<foodtime) a,\r\n" + "photo  p,(SELECT userid,username,a from `user`) as u \r\n"
				+ "WHERE a.foodid=p.suozaiid AND u.userid=a.hosterid AND p.phototype=1 AND p.zhufu=1 ORDER BY interest DESC";
		List<Map<String, Object>> queryList = BaseDao.query.query(sql, new MapListHandler());
		System.out.println(new Gson().toJson(queryList));
	}

}
